import request from '@/utils/request'
import Cookies from 'js-cookie'

export function pageDataApiExamine(data) {
  return request({
    url: '/system/MarketApi/MarketApi/pageExamine',
    method: 'get',
    params: data
  })
}

export function pageDataApiExamineHis(data) {
  return request({
    url: '/system/MarketApi/MarketApi/pageExamineHis',
    method: 'get',
    params: data
  })
}

export function listDataApi(data) {
  return request({
    url: '/system/MarketApi/MarketApi/list',
    method: 'get',
    params: data
  })
}

export function pageDataApi(data) {
  return request({
    url: '/system/data/market/dataApis/page',
    method: 'get',
    params: data
  })
}



export function pageDataApiApply(data) {
  return request({
    url: '/system/MarketApi/MarketApi/pageApply',
    method: 'get',
    params: data
  })
}
export function getDataApi(id) {
  return request({
    url: '/system/data/market/dataApis/' + id,
    method: 'get'
  })
}


export function getDataApiInfo(id) {
  const userName = Cookies.get("examinename")
  return request({
    url: '/system/data/market/dataApis/info',
    method: 'get',
    params: {
      id,
      userName
    }
  })
}

export function delDataApi(id) {
  return request({
    url: '/system/data/market/dataApis/' + id,
    method: 'delete'
  })
}

export function revokeDataApi(id) {
  return request({
    url: '/system/MarketApi/MarketApi/revoke/' + id,
    method: 'get'
  })
}

export function delDataApis(ids) {
  return request({
    url: '/system/data/market/dataApis/batch/' + ids,
    method: 'delete'
  })
}

export function addDataApi(data) {
  return request({
    url: '/system/data/market/dataApis',
    method: 'post',
    data: data
  })
}

  export function useDataApi(apiId) {
    const userName = Cookies.get("examinename");
    return request({
      url: '/system/data/market/dataApis/use',
      method: 'post',
      data: {
        apiId,
        userName
      }
    })
}

export function examineDataApi(id,type) {
  const userName = Cookies.get("examinename");
  return request({
    url: '/system/MarketApi/MarketApi/examine',
    method: 'post',
    data: {
      id,
      type,
      userName
    }
  })
}

export function updateDataApi(data) {
  return request({
    url: '/system/data/market/dataApis/' + data.id,
    method: 'put',
    data: data
  })
}

export function sqlParse(data) {
  return request({
    url: '/system/data/market/dataApis/sql/parse',
    method: 'post',
    data: data
  })
}

export function copyDataApi(id) {
  return request({
    url: '/system/data/market/dataApis/' + id + '/copy',
    method: 'post'
  })
}

export function releaseDataApi(id) {
  return request({
    url: '/system/data/market/dataApis/' + id + '/release',
    method: 'post'
  })
}

export function cancelDataApi(id) {
  return request({
    url: '/system/data/market/dataApis/' + id + '/cancel',
    method: 'post'
  })
}

export function word(id) {
  return request({
    url: '/system/data/market/dataApis/word/' + id,
    method: 'post',
    responseType: 'blob'
  })
}

export function getDataApiDetail(id) {
  return request({
    url: '/system/data/market/dataApis/detail/' + id,
    method: 'get'
  })
}


